﻿using System;
using System.Collections.Generic;
using BobDotNet.Classes.Base;
using NHibernate;

namespace BobDotNet.Classes.Dao
{
    class DaoPrioriteDi
    {
        public static PrioriteDi Charge(string id)
        {
            return DaoPrioriteDi.Charge(Int32.Parse(id));
        }

        public static PrioriteDi Charge(Int32 id)
        {
            return (PrioriteDi)DaoBase.Charge(id, PrioriteDi.NomClasse);
        }

        public static List<PrioriteDi> ChargeTout()
        {
            List<PrioriteDi> retour;
            ISession session = NHibernateSessionManager.Instance.GetSession();
            retour = (List<PrioriteDi>)session.CreateCriteria(typeof(PrioriteDi)).List<PrioriteDi>();
            NHibernateSessionManager.Instance.CloseSession();
            return retour;
        }

        public static void MettreAJour(PrioriteDi lo)
        {
            try
            {
                DaoBase.MettreAJour(lo);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }

        public static void Creer(PrioriteDi lo)
        {
            try
            {
                DaoBase.Creer(lo);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }

        public static void Supprimer(string Id)
        {
            DaoPrioriteDi.Supprimer(Int32.Parse(Id));
        }

        public static void Supprimer(Int32 Id)
        {
            DaoPrioriteDi.Supprimer(DaoPrioriteDi.Charge(Id));
        }

        public static void Supprimer(PrioriteDi lo)
        {
            try
            {
                DaoBase.Supprimer(lo);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
    }
}